# Author:Yiye
# -*- codeing = utf-8 -*-
# @Time :2021/11/13 9:06
# @Author:李卓
# @Site : 
# @File : xpath的基本使用.py
# @Software : PyCharm
from lxml import etree
tree = etree.parse('xpath的使用案例.html')
# list_tree = tree.xpath('//body//ul/li[@id]/text()')
# list_tree = tree.xpath('//body//ul/li[@id]/@class')
# list_tree = tree.xpath('//body//ul/li[contains(@id,"l")]/text()')
list_tree = tree.xpath('//body//ul/li[starts-with(@id,"l")]/text()')




print(list_tree)
print(len(list_tree))